using UnityEngine;
using System.Collections;

public class UIViewAuto : UIView
{
		protected float autoScaleX = 1;
	
		public virtual void setAutoScaleX (float autoScaleX)
		{
				VieworUtils.autoFix (gameObject);
				this.autoScaleX = autoScaleX;
		}

		public virtual bool setAutoHeight (float autoHeight)
		{
				if (contentSize.y == 0 || autoScaleX == 0) {
						return false;
				}
		
				setAutoScaleX (contentSize.y / autoHeight / autoScaleX);
				if (autoScaleX == 1) {
						return true;
				}
		
				if (!VieworUtils.setAutoLayout (gameObject.transform, autoScaleX, contentSize.y)) {
						VieworUtils.setAutoViews (gameObject.transform, autoScaleX, contentSize.y);
				}

				return true;
		}
	
		public void setAutoView (Transform trans)
		{
				setAutoView (trans, 0);
		}
	
		public void setAutoView (Transform trans, float autoHeight)
		{
				if (contentSize.y == 0 || autoScaleX == 1 || VieworUtils.autoFix (trans.gameObject)) {
						return;
				}
		
				VieworUtils.setAutoView (trans, autoScaleX, contentSize.y, autoHeight);
		}
}
